package com.piggy.common.core.enums;

import com.piggy.common.core.exception.base.BaseException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

@Getter
@AllArgsConstructor
public enum AttatchTypeEnums {

    /**
     * 1 采购合同  2 销售合同  3 发票  4 结算单  5物流单  6普通附件  7付款凭证  8定金付款凭证  9货物付款凭证  10仓单附件  11 收货款凭证  12退货款凭证
     */
    CONTACT(1, "合同(缺省)"),
    PURCHASE_CONTACT(1, "采购合同"),
    SALE_CONTACT(2, "销售合同"),
    BILL_INVOICE(3, "发票"),
    BILL_SETTLEMENT(4, "结算单"),
    BILL_LOGISTICS(5, "物流单"),
    BILL_COMMON(6, "普通附件"),
    BILL_PAYMENT(7, "付款凭证"),
    BILL_DEPOSIT_PAYMENT(8, "定金付款凭证"),
    BILL_LOGISTICS_PAYMENT(9, "货物付款凭证"),
    BILL_WAREHOUSE(10, "仓单附件"),
    BILL_RECEIPT_PAYMENT(11, "收货款凭证"),
    BILL_RETURN_PAYMENT(12, "退货款凭证"),
    BILL_SIGNED_SETTLEMENT(31, "签章结算单"),
    BILL_SIGNED_SETTLEMENT1(32, "签章结算单"),

    BILL_SERVICEFEE_PAYMENT(110, "技术服务费付款凭证"),
    BILL_FINANCING_RETURN(111, "融资退款凭证"),
    BILL_ACC_DEDUCTION(112, " 清分扣款凭证"),

    UNKOWN(-1, " 无效类型"),
    ;
    private  final int  code;
    private  final String desc;

    public static AttatchTypeEnums findByCode(int code) {
        return Arrays.asList(AttatchTypeEnums.values()).stream().filter(t -> t.getCode() == code).findFirst().orElse(UNKOWN);
    }

    public static List<AttatchTypeEnums> all() {
        return Arrays.asList(AttatchTypeEnums.values());
    }
}
